package com.aric.springbootmusic.mapper;

import com.aric.springbootmusic.entity.pojo.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RoleMapper extends BaseMapper<Role> {
    //删除rp表中roleId为roleId的数据
    @Delete("""
        delete from rp where role_id=#{roleId}
    """)
    Integer deletePsById(Integer roleId);

    @Insert("<script> "+
                "insert into rp(role_id,ps_id) values "+
                "<foreach collection='psIds' item='psId' separator=','> "+
                    "(#{roleId},#{psId}) "+
                "</foreach> "+
            "</script>"
            )
    Integer addPs(@Param("roleId") Integer roleId, @Param("psIds") List<Integer> psIds);
}
